package com.qd.p2p.web.action;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;

import com.opensymphony.xwork2.ModelDriven;
import com.qdlc.p2p.biz.service.ScoreLogService;
import com.qdlc.p2p.biz.service.ScoreService;
import com.qdlc.p2p.biz.web.action.BaseAction;
import com.qdlc.p2p.dal.common.model.jpa.PageDataList;
import com.qdlc.p2p.dal.dto.Score;
import com.qdlc.p2p.dal.model.ScoreLogModel;

/**
 * 积分记录
 * @author xxx
 * @version 2.0
 * @date 2015年6月23日 下午4:22:48
 */
public class ScoreLogAction extends BaseAction<ScoreLogModel> implements ModelDriven<ScoreLogModel> {
	
	private Map<String, Object> data;
	
	@Resource
	private ScoreService scoreService;
	@Resource
	private ScoreLogService scoreLogService;
	
	/**
	 * 跳转积分兑换列表页
	 * @return
	 */
	@Action("/member/score/log")
	public String log() throws Exception{
		Score score = scoreService.findByUserId(this.getSessionUserId());
		request.setAttribute("userScore",score);
		return "log";
	} 
	
	/**
	 * 积分记录分页
	 * @return
	 */
	@Action("/member/score/log/list")
	public void list() throws Exception{
		model.setUser(getSessionUser());
		PageDataList<ScoreLogModel> page = scoreLogService.findPageList(model);
		data = new HashMap<String, Object>();
		data.put("data", page);
		printWebJson(getStringOfJpaObj(data));
	}
}
